<template>
  <a-modal
    :width="modalWidth"
    :visible="visible"
    title="角色选择"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
    cancelText="关闭"
    @ok="handleOk"
    wrapClassName="ant-modal-cust-warp"
  >
    <div>
      <a-radio-group v-model="value">
        <ul style="list-style-type:none">
          <li v-for="(item, index) in userRoleList" :key="index" :defaultValue="value" >
            <a-radio :value="item" :style="radioStyle">{{item.roleName}}({{item.departName}})</a-radio>
          </li>
        </ul>
      </a-radio-group>
    </div>
  </a-modal>
</template>

<script>

  export default {
    name: "LoginModal",
    components: {
    },
    props :{
      multiple:Boolean,
      checkable:Boolean
    },
    data () {
      return {
        checkedKeys:[], // 存储选中的部门id
        modalWidth:530,
        userRoleList:[],
        title:"操作",
        visible: false,
        value:"",
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        radioStyle: {
          display: 'block',
          height: '30px',
          lineHeight: '30px',
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        headers:{},
        activeIndex: '',
        form:this.$form.createForm(this),
        url: {

        },
      }
    },
    methods: {
      showUserRole(result){
        let that = this;
        this.value=result[0];
            for(let a=0;a<result.length;a++){
              let temp = result[a];
              that.userRoleList.push(temp);
            }
        this.visible = true;
      },
      close () {
        this.visible = false;
        this.userRoleList = [];
        this.checkedKeys = [];
        this.$emit('close');
      },
      handleCancel () {
        this.close()
      },
      handleOk(){
        if(this.value!=""){
          this.$emit('ok',this.value);
        }else{
          this.$message.warning('请先选中一个角色!')
          return false
        }
        this.close();
      }
    },
  }
</script>

<style scoped>
</style>